package com.yjs.app.trade.web.controller.business.statistics;

import java.io.File;
import java.io.IOException;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.io.FileUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.yjs.app.trade.web.controller.base.BaseController;
import com.yjs.app.trade.web.controller.base.util.Result;

import net.sf.json.JSONObject;

/**
 * 发票相关控制层
 * 
 * @author Administrator
 *
 */
@Controller
@RequestMapping(value = "/app/business/statistics")
public class StatisticsJsonController extends BaseController {
	
	/**
	 * @param data
	 * @param request
	 * @return
	 */
	@RequestMapping(value = "/button", method = RequestMethod.GET)
	@ResponseBody
	public Object getButtons(String data, HttpServletRequest request) {
		JSONObject jsonObject = dpackData(data);
		String type = jsonObject.getString("type");
		String path = getClass().getClassLoader().getResource("json/statistics_" + type + "_button.json").toString();
		String json = "";
		try {
			json = FileUtils.readFileToString(new File(path.replace("file:", "")), "UTF-8");
		} catch (IOException e) {
			e.printStackTrace();
		}
		return Result.csuccess(json);
	}
}
